package com.gugee.tiktok.data.common.msg;

import com.gugee.tiktok.data.common.util.ProtostuffUtil;
import lombok.Data;
import lombok.ToString;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serializer;

import java.util.Map;

/**
 * Description:视频消息
 * User: Huang xin
 * Date: 2020-11-18 14:02
 */
@ToString(callSuper = true)
@Data
public class AwemeMessage extends TiktokMessage {

    /**
     * 视频id
     */
    private long awemeId;



    /**
     * 任务消息的反序列号
     *
     */
    public static class MsgDeserializer implements Deserializer<AwemeMessage> {
        @Override
        public void configure(Map map, boolean b) {

        }

        @Override
        public AwemeMessage deserialize(String topic, byte[] bytes) {
            return ProtostuffUtil.deserializer(bytes, AwemeMessage.class);
        }

        @Override
        public void close() {

        }
    }

    /**
     * Description 类描述
     *
     */
    public static class MsgSerializer implements Serializer<AwemeMessage> {

        @Override
        public void configure(Map map, boolean b) {

        }

        @Override
        public byte[] serialize(String topic, AwemeMessage awemeMessage) {
            return ProtostuffUtil.serializer(awemeMessage, AwemeMessage.class);
        }

        @Override
        public void close() {

        }
    }

}

